Skip to content

Port vcfaz to Python 3 and remove legacy py27 directory#1

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/port-vcfaz-to-python3
Draft

Port vcfaz to Python 3 and remove legacy py27 directory#1
Copilot wants to merge 3 commits into
mainfrom
copilot/port-vcfaz-to-python3

Conversation

Copilot AI commented Mar 6, 2026

Copy link
Copy Markdown

Completes the Python 3 (≥3.10) port of the vcfaz package, migrating from the legacy Python 2.7 conda package layout to a src/ layout, and removes the legacy directory entirely.

Python 3 compatibility fixes

src/vcfaz/model.py

  • class _AltRecord(object, metaclass=ABCMeta) replaces __metaclass__ = ABCMeta
  • basestringstr
  • Removed __cmp__ (Python 2 only)
  • Dropped legacy try/except ImportError fallbacks for Counter/OrderedDict

src/vcfaz/parser.py

  • All intra-package imports converted to explicit relative imports (from .model import ...)
  • itertools.izipzip
  • dict.has_key()in operator
  • dict.iteritems()/iterkeys()/itervalues().items()/.keys()/.values()
  • def next(self) renamed to def __next__(self) with next = __next__ alias for backwards compat
  • Gzip handling simplified — always wraps with codecs.getreader on Python 3
  • Invalid regex escape sequences fixed to raw strings

src/vcfaz/sample_filter.py

  • Relative import: from .parser import Reader, Writer
  • xrangerange

src/vcfaz/utils.py

  • readers[i].next()next(readers[i])

src/vcfaz/__init__.py

  • All imports converted to explicit relative imports; exposes Reader, Writer, VCFReader, VCFWriter, Filter, SampleFilter, RESERVED_INFO, RESERVED_FORMAT

Removed

  • pyvcfaz-0.6.8-py27_0/ — entire legacy Python 2.7 directory deleted

Tests

Added tests/test_import.py with smoke tests covering imports and basic in-memory VCF parsing:

# Quick non-installed smoke test
PYTHONPATH=src python -c "import vcfaz; print(vcfaz.__file__)"

# Or run the full smoke test suite
PYTHONPATH=src python -m pytest tests/test_import.py -v
Original prompt

Goal

Create a PR in biofold/Py3VCF that completes the Python 3 (>=3.10) port of the legacy vcfaz package and removes the legacy Python 2 directory.

Background / Context

The repository currently contains a legacy, Python 2.7-era copy of the vcfaz package under:

  • pyvcfaz-0.6.8-py27_0/lib/python2.7/site-packages/vcfaz/

We want to:

  1. Port the package to a modern Python 3 codebase using a src/ layout.
  2. Place the Python 3 port under:
  • src/vcfaz/
  1. Delete the legacy directory:
  • pyvcfaz-0.6.8-py27_0/

Requirements

A. Add Python 3 package sources

Create the following files under src/vcfaz/ with Python 3-compatible code:

  • src/vcfaz/__init__.py
  • src/vcfaz/parser.py
  • src/vcfaz/model.py
  • src/vcfaz/utils.py
  • src/vcfaz/filters.py
  • src/vcfaz/sample_filter.py

Key compatibility fixes include (non-exhaustive):

  • Convert legacy intra-package imports to explicit relative imports (e.g. from .model import ...).
  • Replace Python 2-only APIs:
    • itertools.izip -> zip
    • dict.iteritems()/iterkeys()/itervalues() -> .items()/.keys()/.values()
    • xrange -> range
    • basestring -> str
    • has_key -> in
    • implement iterator protocol (__iter__ + __next__) for Reader.
  • Ensure gzipped VCF handling works correctly on Python 3 (decode bytes to text via codecs reader).
  • Maintain backwards-compatible aliases where present (e.g. VCFReader, VCFWriter) and export public API from src/vcfaz/__init__.py.

B. Remove legacy directory

Delete the entire directory:

  • pyvcfaz-0.6.8-py27_0/

C. Smoke tests / verification

Add minimal smoke tests (can be lightweight and not require external data) or at least include instructions in PR description. Preferably add tests/test_import.py that verifies:

  • import vcfaz works
  • from vcfaz.parser import Reader works

If tests are added, ensure they pass in CI or at least locally.

D. PR details

  • Base branch: main
  • Create a feature branch (suggested name: python3-port if available; otherwise python3-port-2).
  • PR title suggestion: Port vcfaz to Python 3 and remove legacy py27 directory
  • PR should include a clear summary and how to run a quick non-installed smoke test:
    • PYTHONPATH=src python -c "import vcfaz; print(vcfaz.__file__)"

Reference legacy sources

Legacy files to port (current commit context):

  • pyvcfaz-0.6.8-py27_0/lib/python2.7/site-packages/vcfaz/__init__.py
  • pyvcfaz-0.6.8-py27_0/lib/python2.7/site-packages/vcfaz/parser.py
  • pyvcfaz-0.6.8-py27_0/lib/python2.7/site-packages/vcfaz/model.py
  • pyvcfaz-0.6.8-py27_0/lib/python2.7/site-packages/vcfaz/utils.py
  • pyvcfaz-0.6.8-py27_0/lib/python2.7/site-packages/vcfaz/filters.py
  • pyvcfaz-0.6.8-py27_0/lib/python2.7/site-packages/vcfaz/sample_filter.py

Notes

  • Keep changes focused on the vcfaz package port and removal of the legacy directory.
  • If other packaging files (e.g. pyproject.toml) are required for tests/imports, add them as needed, but do not over-scope.

This pull request was created from Copilot chat.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 6, 2026 16:44
Co-authored-by: ecapriotti <5848298+ecapriotti@users.noreply.github.com>
Co-authored-by: ecapriotti <5848298+ecapriotti@users.noreply.github.com>
Copilot AI changed the title [WIP] Complete Python 3 port of legacy vcfaz package Port vcfaz to Python 3 and remove legacy py27 directory Mar 6, 2026
@ecapriotti

Copy link
Copy Markdown
Contributor

accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants